package cn.sjx.modules.nbiot.entity.common;

/**
 * 确认ack枚举对象
 *
 * @Author: sjx
 * @Date: 2019年09月02日 0002 17:57:13
 */
public enum AckEnum {

    /**
     * 0x70：确认ACK 成功
     */
    SUCCESSFUL("0x70", (short) 112),

    /**
     * 0x29: 业务处理未完成，通知检查服务器
     */
    UN_BUSINESS_CHECK_SERVER("0x29", (short) 41),

    /**
     * 0x07：收到同一地磁设备的重复进场数据
     */
    RECEIVED_REPEATED_ARRIVAL_DATA("0x07", (short) 7),

    /**
     * 0x10：收到同一地磁设备的重复离场数据
     */
    RECEIVED_REPEATED_DEPARTURE_DATA("0x10", (short) 16),

    /**
     * 0x17：CRC 验证失败
     */
    CRC_VERIFICATION_FAILED("0x17", (short) 23),

    /**
     * 0x24：地磁设备不存在
     */
    GEOMAGNETIC_NOT_EXIST("0x24", (short) 36),

    /**
     * 0x30：未知错误
     */
    UNKNOWN_MISTAKE("0x30", (short) 48),

    /**
     * 0x00：其它错误
     */
    ERROR_OTHER("0x00", (short) 0);

    /**
     * 构造方法
     *
     * @param key
     * @param value
     */
    private AckEnum(String key, short value) {
        this.key = key;
        this.value = value;
    }

    /**
     * 根据key获取对应的枚举对象
     *
     * @param key
     * @return
     */
    public static AckEnum getAckEnumByKey(String key) {
        for (AckEnum ele : values()) {
            if (ele.getKey().equals(key)) {
                return ele;
            }
        }
        return null;
    }

    // region 成员变量与Setter/Getter

    private String key;

    private short value;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public short getValue() {
        return value;
    }

    public void setValue(short value) {
        this.value = value;
    }

    // endregion
}
